home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / ciao.h < prev    next >
C/C++ Source or Header  |  1988-09-13  |  11KB  |  293 lines

  1. /* ciao.h - declarations for all global data & functions in ciao.lib
  2. **          the module is self-initializing, vid_init() is only required
  3. **          to set a particular text mode (7=mono, or 2=b&w or 3=color,
  4. **          or 0=default, whatever's running).
  5. **
  6. **    --> IT IS RECOMMENDED PRACTICE TO ***ALWAYS*** CALL VID_INIT(n) <--
  7. **
  8. **          this is the revised version developed for fafnir.lib, so
  9. **          the dlrcvt, time and sound functions are in cutils.lib, but
  10. **          use this header file.  9/10/88, d.c.oshel
  11. */
  12.  
  13. #include "vidinit.h"       /* the CIAO library, globals and macros! */
  14.     /* vidinit.h nested includes: 
  15.     **        stdio.h, stdlib.h, dos.h, malloc.h
  16.     */
  17. #include <signal.h>
  18. #include <setjmp.h>
  19. #include <string.h>
  20. #include <ctype.h>
  21.  
  22.  
  23. /*   video attribute info re the wputs() and wprintf() ^ commands
  24. =========================================================================
  25.      There are 16 public Video Attribute Registers:  vid[0] ... vid[15]
  26.  
  27.      Common            VidReg   ^ commands that set the attribute
  28.      -------------------------------------------------------------------
  29.      Normal            vid[0]   wputs("^0"); wputs("^");
  30.      Bold              vid[1]   wputs("^1"); 
  31.      Emphasis          vid[2]   wputs("^2"); 
  32.      Attention!        vid[3]   wputs("^3"); 
  33.  
  34.                        vid[4]   wputs("^4");
  35.                        .
  36.                        .
  37.                        .
  38.                        vid[ 9]  wputs("^9");
  39.                        vid[10]  wputs("^Ω"); keystroke is ALT 234
  40.                        vid[11]  wputs("^δ");      "       ALT 235
  41.                        vid[12]  wputs("^∞");      "       ALT 236
  42.                        vid[13]  wputs("^φ");      "       ALT 237
  43.                        vid[14]  wputs("^ε");      "       ALT 238
  44.                        vid[15]  wputs("^∩");      "       ALT 239
  45.  
  46.  
  47.      The DEFAULT contents of these registers is as follows:
  48.  
  49.      Contents      *Color/Graphics Adapt.   Monochrome Adapter
  50.      -----------------------------------------------------------------
  51.      Normal         brite white on blue     normal
  52.      Bold           brite yellow on black   bright normal
  53.      Emphasis       brite blue on white     reverse
  54.      Attention      blink br. white on red  blinking reverse
  55.  
  56.      vid[ 4]       *red, 4                  underline
  57.      vid[ 5]        magenta, 5              bright underline    
  58.      vid[ 6]        dark yellow, 6          blinking normal
  59.      vid[ 7]        ordinary white, 7       blinking underline
  60.      vid[ 8]        dark grey, 8            blinking bright normal 
  61.      vid[ 9]        brite blue, 9           blinking bright underline
  62.      vid[10]        brite green, 0x0a       normal
  63.      vid[11]        brite cyan, 0x0b        normal
  64.      vid[12]        brite red, 0x0c         normal
  65.      vid[13]        brite magenta, 0x0d     normal
  66.      vid[14]        brite yellow, 0x0e      normal
  67.      vid[15]        brite white, 0x0f       normal
  68.  
  69.      *The default background is black for registers vid[4]..vid[15], and
  70.       blink is off.
  71.  
  72. ==========================================================================
  73. */
  74.  
  75. /* wprintf( fmt, variable_length_argument_list );
  76. **
  77. ** calls wputs, recognizes ^ commands
  78. */
  79.  
  80. extern void wprintf(char *,...);
  81.  
  82.  
  83. /* keyin( wait_fn );
  84. **
  85. ** wait_fn executed while awaiting keyboard input
  86. ** returns characters as positive integers from 1..255
  87. ** returns extended ASCII (Fn keys, etc.) as defined in <keys.h>
  88. **
  89. ** two candidates for the function argument to keyin are acg() or
  90. ** screenwait().  screenwait() calls acg() to bump the generator,
  91. ** blanks out the screen (until user keypress) after 8 minutes of
  92. ** quiet at the console.  keyin( noop ) is also frequent usage.
  93. */
  94.  
  95. extern int keyin(void (*wf)(void ));            /* usually calls screenwait */
  96. extern int getkey(void);                /* keyin(screenwait) with key click */
  97.  
  98. extern unsigned acg( void );     /* additive random number generator, Knuth */
  99. extern void init_acg( void );     /* initialize acg when can't keyin( acg ) */
  100. extern void screenwait( void ); /* screen goes blank after 8 min inactivity */
  101. extern void flush_keys( void );          /* annihilate DOS typeahead buffer */
  102. extern int keyshift_status( void );     /* interrupt 22 shift status report */
  103.  
  104. extern void noop(void );                      /* do nothing, convenient!    */
  105. extern void bell(void );                      /* beep: i.e., putch('\a');   */
  106. extern unsigned int sleep(int n);  /* wait n/10ths second (more or less), 
  107.                                                return 0 or user's keystroke */
  108.  
  109.  
  110.  
  111. /*-------------- these functions are in FUTILITY.LIB -------------*/
  112.  
  113.  
  114. /* sound */
  115.  
  116. extern int tone;                  /* no sound effects if false */
  117.  
  118. extern void HIclack( void );      /* musical gadget declarations */
  119. extern void LOclack( void );
  120. extern void bopbleet( void );
  121. extern void blopbloop( void );
  122. extern void thurb( void );
  123. extern void setfrq( unsigned ); /* sound generation primitives declarations */ 
  124. extern void spkron( void );
  125. extern void spkroff( void );
  126. extern void note( unsigned, unsigned );
  127.  
  128.  
  129. /* dollar longs */
  130.  
  131. extern char *dlrcvt(long );         /* convert long to form 999,999,999.99- */ 
  132. extern char *crdrform(long );            /* same but with trailing Dr or Cr */
  133.  
  134.  
  135. /* tm.h, February 20, 1988, d.c.oshel
  136. **       emulate date and time functions from C Food Smorgasbord
  137. **       (obviously, these are WORK-ALIKES, not the originals!)
  138. */
  139.  
  140.  
  141. /* read system clock (PC/MS-DOS 2.x services)
  142. ** get_system_time() reads valid hundredths of a second, accurate
  143. ** to about 1/20th second depending on the system clock.
  144. ** get_system_date() sets dayofweek as 0=Sunday..6=Saturday
  145. */
  146.  
  147. extern  void get_system_time(int *hr,int *min,int *sec,int *hnd);
  148. extern  void get_system_date(int *year,int *month,int *day,int *dayofweek);
  149.  
  150.  
  151. /* formatted ASCIIZ date and time strings, or BCD byte array
  152. cf_time and cf_date emulate C Food Smorgasbord fns time and date,
  153. with the following mode options controlling format:
  154.  
  155.                 cf_date(ptr,mode)   cf_time(ptr,mode)
  156.  
  157. BCD arrays:
  158.                 3-byte              4-byte          
  159.                 yy mm dd            hh mm ss dd
  160. Mode Option 0. [88,02,20]          [09,55,34,58] 
  161.  
  162. ASCIIZ strings:
  163.  
  164. Mode Option 1.  880220              095534        (24-hr)
  165. Mode Option 2.  02/20/88            09:55:34      (  "  )
  166. Mode Option 3.  02-20-88            09553463      (  "  )
  167. Mode Option 4.  FEB 20, 1988        09:55:34.63   (  "  )
  168. Mode Option 5.  February 20, 1988   09:55         (  "  )
  169. Mode Option 6.  20 FEB 88           09:55:34 AM   (12-hr, AM or PM)
  170. Mode Option 7.  20 FEB 1988         09:55 AM      (       "       )
  171.  
  172. User must allocate, and provide a pointer to, a character buffer which
  173. receives formatted ASCIIZ output.
  174.  
  175. These functions place formatted date and time strings into the user's
  176. receiving buffer, and return a pointer to the '\0' character terminating
  177. the strings.  (Ptr returned may have some use in string concatenation.)
  178.  
  179. Option 0, however, works the same way, but there is NO '\0' terminator
  180. at the end of the receiving 3- or 4-byte array.  The pointer is to the
  181. next byte following the BCD byte array.  (Ptr returned is useless.)
  182.  
  183. Since mode Option 0 returns binary coded decimal, sign extension will be
  184. a consideration for the first byte of the date (year), and the hundredths
  185. byte of the time (ranges up to 99).
  186. */
  187.  
  188. extern  char *cf_time(char *str,int mode);
  189. extern  char *cf_date(char *str,int mode);
  190.  
  191. extern char *Month_table[]; /* "January", etc., 0=NULL, 1..12 */
  192. extern char *MON_table[];   /* "Jan", etc.,     0=NULL, 1..12 */
  193. extern char *Day_table[];   /* "Sunday", etc.,  0=NULL, 1..7  */
  194.  
  195. extern char *sysdate( void ); /* ptr to system date, like "12/25/87" */
  196. extern char *systime( void ); /* ptr to system time, like "18:00:00" */
  197.  
  198. extern void jul2mdy (  long jday,     /* valid Julian Day number */
  199.                        int * mm,      /* Gregorian mont